<?php


abstract class BaseLDAMember extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $name;


	
	protected $password;


	
	protected $email;


	
	protected $phone;


	
	protected $address;


	
	protected $city;


	
	protected $state;


	
	protected $zipcode;


	
	protected $country;


	
	protected $is_member;


	
	protected $member_id;


	
	protected $created_at;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getName()
	{

		return $this->name;
	}

	
	public function getPassword()
	{

		return $this->password;
	}

	
	public function getEmail()
	{

		return $this->email;
	}

	
	public function getPhone()
	{

		return $this->phone;
	}

	
	public function getAddress()
	{

		return $this->address;
	}

	
	public function getCity()
	{

		return $this->city;
	}

	
	public function getState()
	{

		return $this->state;
	}

	
	public function getZipcode()
	{

		return $this->zipcode;
	}

	
	public function getCountry()
	{

		return $this->country;
	}

	
	public function getIsMember()
	{

		return $this->is_member;
	}

	
	public function getMemberId()
	{

		return $this->member_id;
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = LDAMemberPeer::ID;
		}

	} 
	
	public function setName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = LDAMemberPeer::NAME;
		}

	} 
	
	public function setPassword($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->password !== $v) {
			$this->password = $v;
			$this->modifiedColumns[] = LDAMemberPeer::PASSWORD;
		}

	} 
	
	public function setEmail($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = LDAMemberPeer::EMAIL;
		}

	} 
	
	public function setPhone($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->phone !== $v) {
			$this->phone = $v;
			$this->modifiedColumns[] = LDAMemberPeer::PHONE;
		}

	} 
	
	public function setAddress($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->address !== $v) {
			$this->address = $v;
			$this->modifiedColumns[] = LDAMemberPeer::ADDRESS;
		}

	} 
	
	public function setCity($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->city !== $v) {
			$this->city = $v;
			$this->modifiedColumns[] = LDAMemberPeer::CITY;
		}

	} 
	
	public function setState($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->state !== $v) {
			$this->state = $v;
			$this->modifiedColumns[] = LDAMemberPeer::STATE;
		}

	} 
	
	public function setZipcode($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->zipcode !== $v) {
			$this->zipcode = $v;
			$this->modifiedColumns[] = LDAMemberPeer::ZIPCODE;
		}

	} 
	
	public function setCountry($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->country !== $v) {
			$this->country = $v;
			$this->modifiedColumns[] = LDAMemberPeer::COUNTRY;
		}

	} 
	
	public function setIsMember($v)
	{

		if ($this->is_member !== $v) {
			$this->is_member = $v;
			$this->modifiedColumns[] = LDAMemberPeer::IS_MEMBER;
		}

	} 
	
	public function setMemberId($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->member_id !== $v) {
			$this->member_id = $v;
			$this->modifiedColumns[] = LDAMemberPeer::MEMBER_ID;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = LDAMemberPeer::CREATED_AT;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->name = $rs->getString($startcol + 1);

			$this->password = $rs->getString($startcol + 2);

			$this->email = $rs->getString($startcol + 3);

			$this->phone = $rs->getString($startcol + 4);

			$this->address = $rs->getString($startcol + 5);

			$this->city = $rs->getString($startcol + 6);

			$this->state = $rs->getString($startcol + 7);

			$this->zipcode = $rs->getInt($startcol + 8);

			$this->country = $rs->getString($startcol + 9);

			$this->is_member = $rs->getBoolean($startcol + 10);

			$this->member_id = $rs->getString($startcol + 11);

			$this->created_at = $rs->getTimestamp($startcol + 12, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 13; 
		} catch (Exception $e) {
			throw new PropelException("Error populating LDAMember object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(LDAMemberPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			LDAMemberPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isNew() && !$this->isColumnModified(LDAMemberPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(LDAMemberPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = LDAMemberPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += LDAMemberPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = LDAMemberPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = LDAMemberPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getPassword();
				break;
			case 3:
				return $this->getEmail();
				break;
			case 4:
				return $this->getPhone();
				break;
			case 5:
				return $this->getAddress();
				break;
			case 6:
				return $this->getCity();
				break;
			case 7:
				return $this->getState();
				break;
			case 8:
				return $this->getZipcode();
				break;
			case 9:
				return $this->getCountry();
				break;
			case 10:
				return $this->getIsMember();
				break;
			case 11:
				return $this->getMemberId();
				break;
			case 12:
				return $this->getCreatedAt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = LDAMemberPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getPassword(),
			$keys[3] => $this->getEmail(),
			$keys[4] => $this->getPhone(),
			$keys[5] => $this->getAddress(),
			$keys[6] => $this->getCity(),
			$keys[7] => $this->getState(),
			$keys[8] => $this->getZipcode(),
			$keys[9] => $this->getCountry(),
			$keys[10] => $this->getIsMember(),
			$keys[11] => $this->getMemberId(),
			$keys[12] => $this->getCreatedAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = LDAMemberPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setPassword($value);
				break;
			case 3:
				$this->setEmail($value);
				break;
			case 4:
				$this->setPhone($value);
				break;
			case 5:
				$this->setAddress($value);
				break;
			case 6:
				$this->setCity($value);
				break;
			case 7:
				$this->setState($value);
				break;
			case 8:
				$this->setZipcode($value);
				break;
			case 9:
				$this->setCountry($value);
				break;
			case 10:
				$this->setIsMember($value);
				break;
			case 11:
				$this->setMemberId($value);
				break;
			case 12:
				$this->setCreatedAt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = LDAMemberPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setPassword($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setEmail($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setPhone($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setAddress($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCity($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setState($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setZipcode($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setCountry($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setIsMember($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setMemberId($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setCreatedAt($arr[$keys[12]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(LDAMemberPeer::DATABASE_NAME);

		if ($this->isColumnModified(LDAMemberPeer::ID)) $criteria->add(LDAMemberPeer::ID, $this->id);
		if ($this->isColumnModified(LDAMemberPeer::NAME)) $criteria->add(LDAMemberPeer::NAME, $this->name);
		if ($this->isColumnModified(LDAMemberPeer::PASSWORD)) $criteria->add(LDAMemberPeer::PASSWORD, $this->password);
		if ($this->isColumnModified(LDAMemberPeer::EMAIL)) $criteria->add(LDAMemberPeer::EMAIL, $this->email);
		if ($this->isColumnModified(LDAMemberPeer::PHONE)) $criteria->add(LDAMemberPeer::PHONE, $this->phone);
		if ($this->isColumnModified(LDAMemberPeer::ADDRESS)) $criteria->add(LDAMemberPeer::ADDRESS, $this->address);
		if ($this->isColumnModified(LDAMemberPeer::CITY)) $criteria->add(LDAMemberPeer::CITY, $this->city);
		if ($this->isColumnModified(LDAMemberPeer::STATE)) $criteria->add(LDAMemberPeer::STATE, $this->state);
		if ($this->isColumnModified(LDAMemberPeer::ZIPCODE)) $criteria->add(LDAMemberPeer::ZIPCODE, $this->zipcode);
		if ($this->isColumnModified(LDAMemberPeer::COUNTRY)) $criteria->add(LDAMemberPeer::COUNTRY, $this->country);
		if ($this->isColumnModified(LDAMemberPeer::IS_MEMBER)) $criteria->add(LDAMemberPeer::IS_MEMBER, $this->is_member);
		if ($this->isColumnModified(LDAMemberPeer::MEMBER_ID)) $criteria->add(LDAMemberPeer::MEMBER_ID, $this->member_id);
		if ($this->isColumnModified(LDAMemberPeer::CREATED_AT)) $criteria->add(LDAMemberPeer::CREATED_AT, $this->created_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(LDAMemberPeer::DATABASE_NAME);

		$criteria->add(LDAMemberPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setName($this->name);

		$copyObj->setPassword($this->password);

		$copyObj->setEmail($this->email);

		$copyObj->setPhone($this->phone);

		$copyObj->setAddress($this->address);

		$copyObj->setCity($this->city);

		$copyObj->setState($this->state);

		$copyObj->setZipcode($this->zipcode);

		$copyObj->setCountry($this->country);

		$copyObj->setIsMember($this->is_member);

		$copyObj->setMemberId($this->member_id);

		$copyObj->setCreatedAt($this->created_at);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new LDAMemberPeer();
		}
		return self::$peer;
	}

} 